#light

namespace CGraph.DirectedGraph

open System.Collections.Generic
open CGraph.Generic

///<summary>
/// Base graph object.  The root graph is always accessable
/// from any object in the graph.
///</summary>
type IDirectedGraphObject =
    abstract Graph : IDirectedGraph with get

///<summary>
/// Graph Contains overall information about the graph.  The base interface
/// to the graph is read-only.  Specializations will specialize ways
/// to change and update the graph.  Do not assume that any meta-properties
/// (size, order, degree) are efficiently implemented.  Also, do not assume
/// that traversals are simple. i.e. finding all the edges in the
/// graph may entail traversing all vertexes.
///</summary>
and IDirectedGraph =
    interface IDirectedGraphObject
    abstract Vertexes : IVertexCollection with get
    abstract Edges : IEdgeCollection with get
    ///The size of a graph is the number of edges in the graph.
    abstract Size : int with get
    ///The order of a graph is the number of vertexes in the graph.
    abstract Order : int with get

///<summary>
/// Vertexes keep track of incoming and outgoing edges.
///</summary>
and IVertex =
    interface IDirectedGraphObject
    abstract IncomingEdges : seq<IEdge> with get
    abstract OutgoingEdges : seq<IEdge> with get
    ///The degree of a vertex is the number of edges incident
    ///(going into and out of) to the vertex.
    abstract Degree : int with get
    abstract InDegree : int with get
    abstract OutDegree : int with get
    
    

///<summary>
/// An edge in the graph.
///</summary>
and IEdge =
    interface IDirectedGraphObject
    abstract IncomingVertex : IVertex with get
    abstract OutgoingVertex : IVertex with get

///<summary>
/// The collection of all vertexes in the graph.
///</summary>
and IVertexCollection =
    interface seq<IVertex>
    /// Roots are vertexes where the length of the incoming edges is 0
    /// Vertexes with no edges attached at all are roots, not leaves.
    /// Do not assume efficient implementation
    abstract Roots : seq<IVertex> with get
    /// Leaves are vertexes where the length of the outgoing edges is 0 but
    /// have at least one incoming edge.
    /// Do not assume efficient implementation
    abstract Leaves : seq<IVertex> with get

///<summary>
/// The collection of all edges in the graph.
///</summary>
and IEdgeCollection =
    interface seq<IEdge>